<?php

class SettingsController extends \BaseController {

	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function index()
	{
		$smtp = Config::get('mail.host');
        $email = Config::get('mail.from.address');
        $name = Config::get('mail.from.name');
        $username = Config::get('mail.from.username');
        $password = Config::get('mail.password');
        return View::make('setting', compact('smtp', 'email', 'name', 'username', 'password'));
	}


	/**
	 * Show the form for creating a new resource.
	 *
	 * @return Response
	 */
	public function update()
	{
        $smtp = Input::get('smtp');
        $email = Input::get('email');
        $name = Input::get('name');
        $username = Input::get('username');
        $password = Input::get('password');
        Config::set('mail.host', $smtp);
        Config::set('mail.from.address', $email);
        Config::set('mail.from.name', $name);
        Config::set('mail.from.username', $username);
        Config::set('mail.password', $password);
        return Input::all();
//        return Redirect::route('setting.index')->with('message', '信息保存成功，您现在可以发一封测试邮件来验证设置');
	}
}
